package com.test3;

import org.junit.Test;

class Generic<T> {
    private T value;

    public Generic(T value) {
        this.value = value;
    }

    public T getValue() {
        return this.value;
    }

    public void setValue(T value) {
        this.value = value;
    }
}

public class MyTest_01 {

    @Test
    public void test1() {
        Generic<Integer> genericA = new Generic<>(985);
        System.out.println(genericA.getValue());
        Generic<String> genericB = new Generic<>("Hello World");
        System.out.println(genericB.getValue());
    }

    @Test
    public void test2() {
        fun1(new Generic<>(211));
        fun2(new Generic<>(13.14));
        fun3(new Generic<>("Java"));
    }

    /** 泛型通配符 */
    public static void fun1(Generic<?> generic) {
        System.out.println("【内容1】" + generic.getValue());
    }

    /** 设置泛型的上限 */
    public static void fun2(Generic<? extends Number> generic) {
        System.out.println("【内容2】" + generic.getValue());
    }

    /** 设置泛型的下限 */
    public static void fun3(Generic<? super String> generic) {
        System.out.println("【内容3】" + generic.getValue());
    }
}
